package com.panopset.refactorsf;

import java.awt.GridLayout;
import java.awt.LayoutManager;

import javax.swing.JScrollPane;

import com.panopset.sf.Windoc;

/**
 * JTextArea persistent container.
 * 
 * @author Karl Dinwiddie
 * 
 */
public final class PanTextArea extends PanField<JScrollPane> {

	public PanTextArea(final Windoc wd, final String prompt,
			final String toolTipText, final String defaultValue, String key) {
		super(wd, prompt, toolTipText, defaultValue, key);
	}

	@Override
	protected String getGuiValue() {
		return getTextArea().getText();
	}

	@Override
	protected void setGuiValue(String value) {
		getTextArea().setText(value);
	}
	@Override
	public JScrollPane createComponent() {
		return new JScrollPane(getTextArea());
	}

	private TTextArea ta;

	public TTextArea getTextArea() {
		if (ta == null) {
			ta = new TTextArea();
			ta.setToolTipText(ptoolTipText);
		}
		return ta;
	}

	@Override
	protected LayoutManager createLayout() {
		return new GridLayout(1, 1);
	}

	@Override
	protected boolean isValid(final String valueToCheck) {
		return true;
	}

}
